
const { plugin } = require("../../../../common/utils")
const { createTask } = require("../../aaa")
exports.createGameDetectTask = function(config, callback) {
    return createTask(
        Object.assign({}, config || {}, {interval: 200}), 
        (args, context) => {
            let capture = images.captureScreen()
            if (capture == undefined) {
                return 
            }
            let bitmap = capture.getBitmap()
            let result = plugin.detect(bitmap, 0.4)
            let objects = {}
            for (let obj of result) {
                if (objects[obj.label] == undefined) {
                    objects[obj.label] = []
                }
                objects[obj.label].push(obj)
            }
            if (objects["guidance"]) {
                context["detect-black-screen"] = true
            }
            return objects
        }, 
        callback
    ) 
} 